package com.example.demo.controller;

import com.example.demo.config.getCurrentTime;
import com.example.demo.model.service.NoticeService;
import com.example.demo.model.valueObject.Notice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;


@Controller
public class NoticeController {
    private final static String getNoticeUrl = "/generate/getNotice";
    private final static String updateNoticeUrl = "/admin/updateNotice";
    private final static String adminUrl="redirect:/admin";
    @Autowired
    private NoticeService service;
    @PostMapping(updateNoticeUrl)
    public String UpdateNotice(@RequestParam String describe)
    {
        service.deleteNotice();
        Notice notice = new Notice();
        notice.setDescribe(describe);
        notice.setTime(getCurrentTime.getTime());
        service.insertNotice(notice);
        return adminUrl;
    }

}
